﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ewk.Math.Algebra.UnitTests.MatrixTests.DoubleTests
{
    [TestClass]
    public class TransposeTests : DoubleTestBase
    {
        [TestMethod]
        public void Transpose_performs_a_transpose_of_the_matrix()
        {
            /* Matrix 1
                    1   2   3   4   5
                    ------------------
                1 | 1   2   3   4   5
                2 | 2   4   6   8   10
                3 | 3   6   9   12  15
            */

            RowCount = 3;
            ColumnCount = 5;
            var matrix1 = Matrix;

            matrix1.Transpose();

            Assert.AreEqual(RowCount, matrix1.ColumnCount);
            Assert.AreEqual(ColumnCount, matrix1.RowCount);

            for (var i = 0; i < RowCount; i++)
            {
                for (var j = 0; j < ColumnCount; j++)
                {
                    Assert.AreEqual((i + 1)*(j + 1), matrix1[j, i].Value);
                }
            }
        }

        [TestMethod]
        public void Transpose_produces_the_same_matrix_if_the_matrix_is_symetric()
        {
            var matrix1 = Matrix;
            var matrix2 = Matrix<double>.Transpose(matrix1);

            Assert.IsTrue(matrix1 == matrix2);
        }
    }
}